<template>
  <div>
    <h3>添加</h3>
    姓名：<input type="text" v-model="ecut.name"><br>
    密码<input type="text" v-model="ecut.password"><br>
    <button @click="add">添加</button>

    <UserList></UserList>

  </div>
</template>

<script>
  import axios from 'axios'
  import UserList from './components/UserList.vue'
  export default {
    name: "App",
    data(){
      return{
        ecut:{
          name:'',
          password:''
        }
      }
    },
    methods:{
      add(){
        axios.post('http://localhost:8081/api1/add',this.ecut).then(
          resopnse => {
            alert(resopnse.data)
            this.ecut.name=''
            this.ecut.password=''
            this.$bus.$emit('updateList')
          },
          error => {alert(error.message)}
        )
      }
    },
    components:{UserList}
  }
</script>